<%@page import="org.springframework.security.core.context.SecurityContextHolder"%>
<%@page import="org.apache.commons.lang.StringUtils"%>
<%@page import="org.apache.commons.lang.time.DateFormatUtils"%>
<%@page import="org.springframework.util.CollectionUtils"%>
<%@page import="java.util.Collection"%>
<%@ include file="../common/common_include.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%

String userName = SecurityContextHolder.getContext().getAuthentication().getName();
String nowDate = DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss");
TblSiteNews news = (TblSiteNews)request.getAttribute("news");
String isShow = StringUtils.isNotBlank(news.getIsShow())?news.getIsShow():"0";

%>
<div>
		<form id="newsFORM" name="form" target="coreIframe"
			action="<%=request.getContextPath()%>/site/doNewsEdit" method="post" enctype="multipart/form-data">
			<div class="breadcrumb">
				<div class="bcIcon"></div>
				<ul class="bcNav">
					<li>编辑新闻</li>
				</ul>
			</div>
		<input type="hidden" value="<%=news.getId() %>" name="id">
			<table class="formTable">
				<tr>
					<td class="tdTitle">新闻类型:</td>
					<td><select name="type">
							<option value="0" id="gongsi" >公司新闻</option>
							<option value="1" id="hangye">行业新闻</option>
					</select></td>
				</tr>
				
				<tr>
					<td class="tdTitle">来源:</td>
					<td><input class="inputText xxs" name="newsSource" value="<%=StringUtils.isNotBlank(news.getNewsSource())?news.getNewsSource():"" %>"></td>
				</tr>

				<tr>
					<td class="tdTitle">发布时间:</td>
					<td>
						<input class="inputText xs" type="text" name="publicTime" disabled="disabled"
						value="<%=(null!=news.getPublicTime())?DateFormatUtils.format(news.getPublicTime(), "yyyy-MM-dd HH:mm:ss"):""%>"/>
					</td>
				</tr>
				<tr>
					<td class="tdTitle">发布人:</td>
					<td><input class="inputText xs" type="text" name="publicMan"
						checkNull="true" placeholder="请输入标题" value="<%=news.getPublicMan()%>" /></td>
				</tr>
				<tr>
					<td class="tdTitle">标题:</td>
					<td><input class="inputText l" type="text" name="title"
						checkNull="true" placeholder="请输入标题" value="<%=news.getTitle() %>" /><span class="errorTipWrap" id="errorTip_title"></span></td>
				</tr>
				<tr>
					<td class="tdTitle">摘要:</td>
					<td><input class="inputText l" type="text" name="newsAbstract"
						checkNull="true"  value="<%=StringUtils.isNotBlank(news.getNewsAbstract())?news.getNewsAbstract():"" %>" /></td>
				</tr>				
				<tr>
					<td class="tdTitle">可选属性:</td>
					<td class="" colspan="2">
						<div class="checkbox-wrap">
							<label>
								<input id="setTop" type="checkbox" value="1" name="istop" class="checkbox"
								<%=news.getIsTop().equalsIgnoreCase("1")?"checked=checked":""%>
								>
								<span>置顶</span>
							</label>
							<label>
								<input id="setImportant" type="checkbox" value="1" name="isimportant" class="checkbox"
								<%=news.getIsImportant().equalsIgnoreCase("1")?"checked=checked":""%>
								>
								<span>重要</span>
							</label>
						</div>
					</td>
				</tr>
				<tr>
					<td class="tdTitle">图片:</td>
					<td><input type="file" name="imgFile" id="up">
					<span style="color:#ff5a00">尺寸要求：宽280px 高200px</span>
						<div>
						<img id="imgPreview" width="70" height="50" src="<%=request.getContextPath() %>/imagextra/<%=news.getPicture()%>" />
						</div>
					</td>
				</tr>	

				<tr>
					<td class="tdTitle">详细内容：</td>
					<td class="" colspan="2">
						<div style="padding-top: 10px; padding-bottom: 10px;">
							<textarea id="content" name="content"
								style="width: 700px; height: 300px; visibility: hidden;"><%=news.getContent() %></textarea>
						</div>
						<span class="errorTipWrap" id="errorTip_content"></span>
					</td>
				</tr>
				<tr>
					<td class="tdTitle">发布:</td>
					<td>
						<label> 
							<input id="isShow" type="radio" name="isShow" value="0" <%=isShow.equalsIgnoreCase("0")?"checked=checked":""%> /><span>暂不发布</span>
						</label> 
						<label> 
							<input id="isShow" type="radio" name="isShow" value="1" <%=isShow.equalsIgnoreCase("1")?"checked=checked":""%> /><span>立即发布</span>
						</label> 
					</td>
				</tr>
				
				<tr>
					<td class="tdTitle"></td>
					<td>
						<div>
							<input class="input-btn-microsoft" type="submit" value="提交">
							<a class="a-btn-microsoft"
								href="javascript:XF.Site.requestUrl('/site/news')">取消</a>
						</div>
					</td>
				</tr>
			</table>
		</form>
</div>
<iframe name="coreIframe" style="display: none"></iframe>
<script type="text/javascript">
	$(function() {
		XF.createKindEditor("content");
		$("input[name=newsSource]").focus();
		var type=<%=news.getType()%>;
		if(type=="0")
			$("#gongsi").attr("selected","selected");
		if(type=="1")
			$("#hangye").attr("selected","selected");
		$("#up").uploadPreview({ Img: "imgPreview", Width: 152, Height: 100 });

	}); 
</script>
</html>